<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>

<body>
    <script>
        var ary = [54, 65, 43, 21, 12, 34, 45, 58, 97, 24];
        var max = ary[0];
        var min = ary[0];
        for (var i = 1; i < ary.length; i++) {
            var cur = ary[i];
            cur > max ? max = cur : null;
            cur < min ? min = cur : null;
        }
        console.log(max)
        console.log(min)


        //判断数组最大值和最小值
        function s(a,b){
            return a-b;
        }
        console.log(ary.sort(s).pop())
        console.log(ary.sort(s).shift())
    </script>
</body>

</html>